package com.ctgu.controller;

import com.ctgu.entity.Information;
import com.ctgu.service.InformationService;
import com.ctgu.utils.RegexUtils;
import com.google.gson.Gson;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author nepture
 */
@RestController
@RequestMapping("/Information")
public class InformationController {

    @Resource
    InformationService informationService;

    @Resource
    Gson gson;

    /**
     * @param information 搜索
     * @return 返回搜索的结果
     */
    @GetMapping
    public String getInformation(@RequestBody Information information) {
        if (!RegexUtils.CheckTel(information.getTelephone())) {
            return gson.toJson("手机号输入错误");
        }
        return gson.toJson(informationService.selectAllUser(information));
    }
}
